﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Linq;
using System.Reflection;
using System.Windows.Forms;

using AimGameLibrary;

namespace AimGameEngine.NodeEditorObject
{
    partial class PropretyRectangle : Form
    {
        NodeRectangle rectangleData;
        public PropretyRectangle(NodeRectangle rectangle)
        {
            InitializeComponent();

            rectangleData = rectangle;
            this.numX.Value = rectangleData.myrectangle.X;
            this.numY.Value = rectangleData.myrectangle.Y;
            this.numWidth.Value = rectangleData.myrectangle.Width;
            this.numHeight.Value = rectangleData.myrectangle.Height;
            this.InputMode.SelectedItem = rectangleData.InputMode.ToString();
        }

        private void okButton_Click(object sender, EventArgs e)
        {
            String tempString = (String)this.InputMode.SelectedItem;
            String tempOldmode = rectangleData.InputMode.ToString();

            if (tempString == NodeInputMode.Int_4.ToString())
                rectangleData.InputMode = NodeInputMode.Int_4;
            else if (tempString == NodeInputMode.Rectangle_1.ToString())
                rectangleData.InputMode = NodeInputMode.Rectangle_1;
            else rectangleData.InputMode = NodeInputMode.None;

            if (rectangleData.InputMode == NodeInputMode.None)
            {
                rectangleData.myrectangle.X = (int)this.numX.Value;
                rectangleData.myrectangle.Y = (int)this.numY.Value;
                rectangleData.myrectangle.Width = (int)this.numWidth.Value;
                rectangleData.myrectangle.Height = (int)this.numHeight.Value;
            }

            if (tempOldmode != tempString)
            rectangleData.SetupProprety();
        }

        private void InputMode_SelectedIndexChanged(object sender, EventArgs e)
        {
            String tempString = (String)this.InputMode.SelectedItem;

            if (tempString != NodeInputMode.None.ToString())
            {
                numX.Enabled = false;
                numY.Enabled = false;
                numWidth.Enabled = false;
                numHeight.Enabled = false;
            }
            else {
                numX.Enabled = true;
                numY.Enabled = true;
                numWidth.Enabled = true;
                numHeight.Enabled = true;
            }
        }
    }
}
